#!/bin/bash

#! amount args
# ${_is_amount_arg} ${NARGS} min_equ max_equ
# if [ $? -ne 0 ]; then
#     plt_pause "${_is_amount_arg}:: be return 1 <- Fail: ${FNLOCK}"
#     return 1
# fi
#! normalize ptr_path -> absolut path
# ptr_path=$1
# ptr_path=$(${_abs_path} $PPWD "ptr_path") #ptr args
#! variables for cr_f_dir_insert_
# fn_name=$(${_prs_f} -n ${arg_path})
# root_path=$(${_prs_f} -d ${arg_path})
#! search in array
# [[ " ${arr[*]} " =~ " $1 " ]] && echo "true" || echo "false"
#! ${array[@]:1} all from 1 member arr

# echo -e "${GREEN}\${g_args[@]} = ${g_args[*]}${NORMAL}" #print variable
# echo -e "${GREEN}\${e_args[@]} = ${e_args[*]}${NORMAL}" #print variable
# echo -e "${GREEN}\${f_args[@]} = ${f_args[*]}${NORMAL}" #print variable
# echo -e "${GREEN}\${ARGS[@]} = ${ARGS[*]}${NORMAL}"     #print variable
# echo -e "${GREEN}\${ARGS0} = ${ARGS0}${NORMAL}"         #print variable
# echo -e "${GREEN}\${ARGS1} = ${ARGS1}${NORMAL}"         #print variable
# echo -e "${GREEN}\${ARGS2} = ${ARGS2}${NORMAL}"         #print variable

# echo -e "${GREEN}\${dir_fns_} = ${dir_fns_}${NORMAL}" #print variable

# echo -e "${GREEN}\${local_var_wrap_arr[@]} = ${local_var_wrap_arr[*]}${NORMAL}" #print variable
# echo -e "${GREEN}\${local_var_fn_arr[@]} = ${local_var_fn_arr[*]}${NORMAL}"     #print variable

# echo -e "${GREEN}\$ratis = $ratis${NORMAL}" #print variable

# echo "that ${FNN}.sal"

#?--------------------------------------------------------
#?---------------------------------------------
#?---------------------------------------

ptr_path=${ARGS0}
ptr_path=$(${_abs_path} $PPWD "ptr_path") #ptr args

second_char=${ARGS1}

if [ -n "$second_char" ]; then

    # for item in $(cat "$ptr_path"); do

    #     # echo $item
    #     fs=${item:0:1}
    #     fs2=${item:1:1}

    #     if [ "$fs" == "#" ] && [ "$item" != "" ] && [ "$fs2" == "$second_char" ]; then
    #         res_item=${item:2}
    #         echo "$res_item"
    #     fi

    # done

    while IFS= read -r line; do
        fs=${line:0:1}
        fs2=${line:1:1}

        if [ "$fs" == "#" ] && [ "$line" != "" ] && [ "$fs2" == "$second_char" ]; then
            res_item=${line:2}
            echo "$res_item"
        fi
    done <"$ptr_path"

elif [ -z "$second_char" ]; then

    if [ -n "$ptr_path" ]; then

        # for item in $(cat "$ptr_path"); do 

        #     # echo $item
        #     fs=${item:0:1}
        #     if [ "$fs" != "#" ] && [ "$item" != "" ]; then
        #         eval echo "$item"
        #     fi

        # done

        while IFS=' 
' read -r line; do
            # echo -e "${GREEN}\$line = $line${NORMAL}" #print variable
            fs=${line:0:1}
            if [ "$fs" != "#" ] && [ "$line" != "" ]; then
                # echo -e "${HLIGHT}--- eval echo $line ---${NORMAL}" #start files
                # eval "echo $line"
                echo $line
            fi 
        done <"$ptr_path"

    else

        ${_plt_exit_} " first argument mast exist "
        return 1

    fi
fi

#?---------------------------------------
#?---------------------------------------------
#?--------------------------------------------------------
